package com.ruoyi.business.controller;

import cn.dev33.satoken.annotation.SaCheckPermission;
import com.ruoyi.business.domain.dto.admin.koc.TaskCheckDTO;
import com.ruoyi.business.domain.dto.admin.koc.TbUserKocTaskInfoPageDTO;
import com.ruoyi.business.domain.vo.PreTaskCheckVO;
import com.ruoyi.business.domain.vo.TbUserKocTaskGroupInfoVO;
import com.ruoyi.business.domain.vo.TbUserKocTaskInfoAllVO;
import com.ruoyi.business.service.koc.ITbUserKocTaskInfoService;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.page.TableDataInfo;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

/**
 * koc 任务列表
 *
 * @author chenran
 */
@Validated
@Api(value = "koc用户任务审核列表", tags = {"koc用户任务审核列表"})
@RequiredArgsConstructor
@RestController
@RequestMapping("/business/user/koc/task/info")
public class TbUserKocTaskInfoController extends BaseController {

    @Resource
    private ITbUserKocTaskInfoService tbUserKocTaskInfoService;


    @ApiOperation("分页查询koc用户任务审核列表")
    @SaCheckPermission("business:user:task:info:page")
    @GetMapping("/list")
    public TableDataInfo<TbUserKocTaskGroupInfoVO> pageQuery(TbUserKocTaskInfoPageDTO dto, PageQuery pageQuery) {
        return tbUserKocTaskInfoService.selectPageList(dto, pageQuery);
    }


    @ApiOperation("根据userId 与 taskId 查询用户koc任务完成情况")
    @SaCheckPermission("business:user:task:info:queryUserTaskInfoByTaskId")
    @GetMapping("/queryUserTaskInfoByTaskId")
    public R<TbUserKocTaskInfoAllVO> userTaskList(
        @ApiParam("userId") @RequestParam(required = true) Long userId,
        @ApiParam("taskId") @RequestParam(required = true) Long taskId,
        @ApiParam("koc期次") @RequestParam(required = true) String kocDate,
        @ApiParam("审核状态 0 未审核 1 审核通过 2 审核不通过 3 已审") @RequestParam(required = false) Integer checkStatus) {
        return R.ok(tbUserKocTaskInfoService.selectUserTaskAllInfo(userId, taskId, kocDate, checkStatus));
    }

    @ApiOperation("审核")
    @PostMapping("task-check")
    @SaCheckPermission("business:user:task:info:taskCheck")
    public R<Boolean> taskCheck(@Validated @RequestBody TaskCheckDTO dto) {
        return R.ok(tbUserKocTaskInfoService.taskCheck(dto));
    }

    @ApiOperation("预审核")
    @PostMapping("pre-task-check")
    public R<PreTaskCheckVO> preTaskCheck(@Validated @RequestBody TaskCheckDTO dto) {
        return R.ok(tbUserKocTaskInfoService.preTaskCheck(dto));
    }




}
